import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:lepig/model/ProductModel.dart';
// 横排正方形多个商品
class GoodsHorizontalMore extends StatelessWidget{
  GoodsHorizontalMore(this.productModel);
  ProductModel productModel;
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return  new Container(
      height: 400.0,
      width: 130.0,
      alignment: Alignment.centerLeft,
      padding: EdgeInsets.all(10.0),
      decoration: new BoxDecoration(
        color: Colors.white,
      ),
      child: new GestureDetector(
        onTap: (){

          Navigator.of(context).pop();// 销毁当前页面
          Navigator.pushNamed(context,"/product",arguments: productModel);
        },
        child: new Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            double.parse(productModel.couponPrice)>0?new Stack(
               children: <Widget>[
                 new ClipRRect(
                   child: new Image.network(productModel.pic,fit: BoxFit.cover,width: 130.0,height: 120.0,),
                   borderRadius: BorderRadius.circular(10.0),
                 ),
                  new Positioned(
                   bottom: 0,
                   left: 0,
                   child: new Container(
                     padding: EdgeInsets.only(left: 5,right: 5,top:2,bottom: 2,),
                     decoration: BoxDecoration(
                       color: Color.fromRGBO(255, 108, 39,1),
                       borderRadius: BorderRadius.only(topRight: Radius.circular(10.0)),
                         gradient: LinearGradient(colors: [Color.fromRGBO(253, 106, 40,1), Color.fromRGBO(251, 61, 61,1)], begin: FractionalOffset(1, 0), end: FractionalOffset(0, 1))
                     ),
                     child: new Text(productModel.couponPrice+"元优惠券",style: TextStyle(
                       color: Colors.white,
                       fontSize: 12.0,
                     ),),
                   ),
                 )
               ],
             ):new SizedBox(),
            new SizedBox(
              height: 5.0,
            ),
            new Text(productModel.title,
            maxLines: 1,
            overflow: TextOverflow.ellipsis,
            style: TextStyle(
              fontSize: 14.0,
              fontWeight: FontWeight.w500
            ),),
            new SizedBox(
              height: 5.0,
            ),
            new Row(
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[

                new Text("￥"+productModel.finalPrice,style: TextStyle(
                    color: Color.fromRGBO(254, 78, 80,1),
                    fontSize: 14.0,
                    fontWeight: FontWeight.bold
                ),),
                new Text(" ￥"+productModel.originalPrice,
                  style: TextStyle(
                      color: Color.fromRGBO(189, 188, 188,1),
                      decoration: TextDecoration.lineThrough,
                      fontSize: 11.0
                  ),
                ),
              ],
            )
          ],
        ),
      ),
    );
  }

}